<!DOCTYPE html>
<html th:lang="${language}" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header(#{okr.my})" />
    <th:block th:include="include :: okr-css" />
</head>
<body>
<div class="col-sm-12 select-table table-striped">
    <table id="bootstrap-table"></table>
</div>

<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix = "/okr/synergy"
    var source = [[${source}]]
    $(function (){
            var options = {
                url : prefix + "/userList",
                columns : [
                    {
                        field: 'userId',
                        visible: false
                    },
                    {
                        field: 'userName',
                        title: '用户名'
                    },
                    {
                        title: '添加协同',
                        align: 'center',
                        formatter: function(value, row, index){
                            var actions = []
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="addSynergy(\'' + row.userId + '\')"><i class="fa fa-edit"></i>协同</a>')
                            return actions.join('')
                        }
                    }
                ]
            }
            $.table.init(options)
        }
    )

    function addSynergy(userId){
        // $.operate.post(prefix + "/addSynergy", { "userId" : userId, "okrId" : source})
        $.ajax({
            url: prefix + "/addSynergy",
            data: { "userId" : userId, "okrId" : source},
            type: 'POST',
            success: function(data){
                if(data.code === 500){
                    $.modal.msg(data.msg, modal_status.FAIL)
                }else{
                    $.modal.msgReload(data.msg, modal_status.SUCCESS)
                }
            }
        })

    }
</script>
</body>
</html>